home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Libraries
/
ExceptionHandler-C-src
/
MyExceptionHandler.h
< prev
next >
Wrap
Text File
|
1990-09-03
|
3KB
|
69 lines
/************************************************************************
By R. Mark Fleming Think C V3.02 Signal Routines....
EMail: flemingm@QUCDN.QueensU.CA
Phone: (613) 545-9732 (h), (613) 545-2039 (w)
SMail: 521 Albert Street
Kingston, Ont.
Canada, K7K 4M5
Description: This is modelled after Apple's MPW's exception handler/
Signals routines that are in sample code...
Note: I have uses the same Prototyping as Apple routines (in fact they
are a copy of apple's prototype def's).
Creation Date: January 31, 1990
special note:
I have not tested these routines very well, but they did work to
compile Apple's "AppleTalk GetZoneList Sample Application", so use at
your own risk...
You may use, modify and redistribute BUT NOT SELL this code provided
that all changes/bug fixes are returned to the author for inclusion.
************************************************************************/
typedef struct {
long regs[11]; /* D3-D7/A2-A7 */
short error;
long message;
long failA6;
long failPC;
Ptr nextInfo; /* Handler */
long whoPC; /* Next FI structure */
short whatSignals;
/* this is used to keep the old stack frame return address */
long sigFRet;
} FailInfo, *PFailInfo;
/* Call the following initialization routine before your other initializations (InitGraf, etc.)-
in other words as early as you can in the application. */
extern pascal void InitUFailure();
/* Allocates the heap block for CatchSignals and initializes the global
variables used by the unit. C programs must use this instead of InitSignals. */
extern pascal void Signal(short);
/* Returns control to the point of the last CatchSignal/CatchFailures. The program will
then behave as though that CatchSignal had returned with the code parameter
supplied to Signal. If CatchCFailures is catching, the message parameter will be 0. */
extern pascal void SignalMessage(short, long);
/* Returns control to the point of the last CatchSignal.
If CatchCFailures is catching, the message parameter will be returned. */
extern pascal void CatchCFailures(/* FailInfo *, ProcPtr */);
/* Call this to set up an exception handler. This pushes your handler onto
a stack of exception handlers. */
extern pascal void Failure(short, long);
/* Call this to signal a failure. Control will branch to the most recent
exception handler, which will be popped off the handler stack. */
extern pascal void Success(FailInfo *);
/* Call this when you want to de-install your exception handler (pop 1
element off the handler stack). */